package com.hongfeng.web.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hongfeng.web.dao.AutoTypeDao;
import com.hongfeng.web.item.QueryItem;
import com.hongfeng.web.item.tag.FieldOperator;
import com.hongfeng.web.model.AutoType;
import com.hongfeng.web.service.AutoTypeService;

@Service
public class AutoTypeServiceImpl implements AutoTypeService {

	@Resource
	private AutoTypeDao autoTypeDao;

	public List<AutoType> findAll() {
		return this.autoTypeDao.findAll();
	}

	public List<AutoType> findByBrandId(Long brandId) {
		QueryItem item = new QueryItem(AutoType.class);
		if (brandId != null) {
			item.addCondition("autoBrand.id", FieldOperator.EQUAL,
					brandId.longValue());
		}
		return autoTypeDao.findAll(item);
	}

	public List<AutoType> findByBrandName(String name) {
		QueryItem item = new QueryItem(AutoType.class);
		if (name != null) {
			item.addCondition("autoBrand.name", FieldOperator.LIKE, name);
		}
		return autoTypeDao.findAll(item);
	}

}
